package com.acaomei.skype.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.acaomei.skype.common.Result;
import com.acaomei.skype.common.ResultVo;
import com.acaomei.skype.dao.IUserDao;
import com.acaomei.skype.entity.User;
import com.acaomei.skype.interceptor.MyInsulateHelper;
import com.acaomei.skype.service.IUserService;
import com.acaomei.skype.util.BeanUtil;
import com.acaomei.skype.util.PageUtil;
import com.acaomei.skype.util.PagedResult;

@Service("userService") 
public class UserServiceImpl implements IUserService{
	@Resource    
    private IUserDao userDao;

	@Override
	public PagedResult<User> getAllUser(User user,Integer pageNo,Integer pageSize) {
		PageUtil.startPage(pageNo,pageSize);
		List<User> userList = userDao.getAllUser(user);
		return BeanUtil.toPagedResult(userList);
	}

	@Override
	public Result<String> addUserInfo(User user) {
		MyInsulateHelper.startInsulate("test");
		Long id = userDao.insertUserInfo(user);
		return ResultVo.successResultMessage("添加成功",id+"");
	}
	
	public Result<String> addBatchUserInfo(List<User> userList){
		//MyInsulateHelper.startInsulate("test");
		Long id = userDao.insertUserInfoForeach(userList);
		return ResultVo.successResultMessage("添加成功",id+"");
	}
}
